<?php
/** 跨域请求设置请求头 **/
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: PUT, GET, POST, OPTIONS");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization");
/** 设置异常处理器 *
 * @param $exception
 */
function myException($exception){
    echo '错误行号['.$exception->getLine().'] in '.$exception->getFile()
        .': <b>'.$exception->getMessage();
    die();
}
set_exception_handler('myException');
/** 错误处理函数 *
 * @param $errno
 * @param $errstr
 * @param $errfile
 * @param $errline
 */
function customError($errno, $errstr, $errfile, $errline)
{
    echo "<b>Custom error:</b> [$errno] $errstr<br />";
    echo " Error on line $errline in $errfile<br />";
    echo "Ending Script";
    die();
}
set_error_handler("customError");

/** 用来引入测试环境：就是给个 <pre>标签 **/
function testEnvironment(){
    echo "<pre>";
}
function println($data){
    testEnvironment();
    var_dump($data, "<br>");
}